package org.yylnb.openplatform.search.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.yylnb.openplatform.search.service.SearchService;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author RainLin
 * @date 2020/8/1 - 11:14
 */
@RequestMapping("/search")
@RestController
public class SearchController {
    @Autowired
    private SearchService searchService;

    @RequestMapping("/searchlog")
    public List<Map> searchLog(String jsonParam) {

        try {
            return searchService.search(jsonParam);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    @RequestMapping("/count")
    public Long getCount(String jsonParam){
        try {
            return searchService.getCount(jsonParam);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    @GetMapping("/statavg")
    public Map<String, Integer> statAvg(String receiveStartTime, String receiveEndtTime){

        try {
            return searchService.statAvg(receiveStartTime,receiveEndtTime);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new HashMap<>();
    }
}


